package com.fh.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

public class Authentication {
	/*
	 * 初级身份认证
	 */
       @SuppressWarnings("finally")
	public static String primary(String name,String number){  
  		 String host = "https://checkcard.market.alicloudapi.com";
		    String path = "/idcard";
		    String method = "POST";
		    String appcode = "a40e3c1ee240453ba3c9e00ad7b4c989";  //秘钥
		    String result="";
		    Map<String, String> headers = new HashMap<String, String>();
		    
		    headers.put("Authorization", "APPCODE " + appcode);
		    Map<String, String> querys = new HashMap<String, String>();
		    querys.put("cardNo", number);
		    querys.put("realName", name);
		    Map<String, String> bodys = new HashMap<String, String>();
		    try {
		    	HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
		    	System.out.println(response.toString());
		    	//获取response的body
              result = EntityUtils.toString(response.getEntity());
             
		    } catch (Exception e) {
		    	e.printStackTrace();
		    }finally{
		    	return result;
		    }
       }
}
